package Thread;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 中断线程之自定义标记位
 */
public class ThreadDemo9 {
    private static boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            while(!isQuit) {
                System.out.println("hello");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();
        Thread.sleep(5000);
        isQuit = true;
        System.out.println("终止 t 线程");
    }
}
